package com.bw.wxy.mvp.view;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.bw.wxy.R;
import com.bw.wxy.common.SpUtils;
import com.bw.wxy.db.UserManager;
import com.bw.wxy.mvp.model.entity.UserEntity;

import org.greenrobot.eventbus.EventBus;

public class LogoutActivity extends AppCompatActivity implements View.OnClickListener{

    private Button logout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logout);
        initView();

    }

    private void initView() {
        logout = findViewById(R.id.logout);
        logout.setOnClickListener(this::onClick);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.logout:
                UserManager.getInstance().getDaoSession().deleteAll(UserEntity.class);
                SpUtils.editFalseLogin();
                EventBus.getDefault().postSticky("退出登录");
                finish();
                break;
        }
    }
}